package br.com.core.dao;

import br.com.core.entitie.Usuario;

public class UsuarioDao extends DaoFactory{
	
	public Usuario buscarUsuario(long id){
		Usuario u = null;
		
		try{
			conectar(this.getClass().getName()+".buscarUsuario");
			
			StringBuilder q = new StringBuilder();
			
			q.append("SELECT SASUsuario as nome, SASUsuario_ID as id FROM SASUsuarios WITH(NOLOCK) ");
			q.append("WHERE SASUsuario_ID=?");
			
			System.out.println(q.toString());
			pstm = connection.prepareStatement(q.toString());
			
			pstm.setLong(1, id);
						
			rs = pstm.executeQuery();
			
			if(rs.next()){
				u = new Usuario();
				u.setNome(rs.getString("nome"));
				u.setId(rs.getLong("id"));
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			desconectar();
		}
		
		return u;
	}
	
}

